package mapper;

import com.sqsf.bean.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {

    @Update({
            "<script>",
            "UPDATE user",
            "<set>",
            "<if test='username != null and username !=\"\"'>username = #{username},</if>",
            "<if test='password != null and password !=\"\"'>password = #{password},</if>",
            "<if test='phone != null and phone != \"\"'>phone = #{phone},</if>",
            "</set>",
            "WHERE uid = #{uid}",
            "</script>"
    })
    public boolean updateByUser(User user);

    @Delete({
            "<script>",
            "DELETE FROM user",
            "WHERE uid IN",
            "<foreach item='uid' collection='list' open='(' separator=',' close=')'>",
            "#{uid}",
            "</foreach>",
            "</script>"
    })
    public boolean deleteByArray(@Param("list") List<Integer> list);
}
